Skip to content

Encode interpolated values in static ~p urls - #6911

Open
ARAYN7011 wants to merge 1 commit into
phoenixframework:mainfrom
ARAYN7011:fix/verified-routes-static-url-encoding
Open

ARAYN7011 wants to merge 1 commit into
phoenixframework:mainfrom
ARAYN7011:fix/verified-routes-static-url-encoding

Conversation

@ARAYN7011

Copy link
Copy Markdown

Fixes #6909

For paths under a configured :statics prefix, url/1,2,3 passed the original ~p route to static_url/2, so interpolated values were not percent-encoded, unlike ~p paths and non-static urls. rewrite_path/4 now also builds a static_url AST from the rewritten (encoded) route, mirroring the existing static path handling.

Test plan

  • New test in verified_routes_test.exs checks that ~p, path/2, url/1 and url/2 all encode a/b?x=1# the same way under a static prefix. It fails before the change and passes after.
  • mix test test/phoenix/verified_routes_test.exs test/phoenix/router passes; changed files are formatted.

AI disclosure: this change was prepared with AI assistance (Claude Code) and reviewed before submission.

url/1,2,3 passed the original ~p route to static_url/2 for static
paths, skipping the percent-encoding of interpolated values that ~p
paths and non-static urls get. Pass the rewritten route instead.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VerifiedRoutes.url skips percent-encoding interpolated values on static paths

1 participant